﻿using System.IO;

namespace TfsWrapper.Tests
{
    public class SpyWriter : IOutputWriter
    {
        private TextReader reader;
        private readonly StringWriter inner;

        public SpyWriter()
        {
            inner = new StringWriter();
        }

        public string Written { get { return inner.GetStringBuilder().ToString(); } }

        public string NextLine
        {
            get { return (reader ?? (reader = new StringReader(Written))).ReadLine(); }
        }

        public void WriteLine()
        {
            inner.WriteLine();
        }

        public void WriteLine(string fieldName, object fieldValue)
        {
            inner.WriteLine(fieldValue);
        }
    }
}